{% extends "zinnia/base.html" %}
{% load i18n tagging_tags comments zinnia_tags %}

{% block title %}{{ object.title }}{% endblock %}

{% block meta-description %}{% if object.excerpt %}{{ object.excerpt|striptags }}{% else %}{{ object.content|striptags|truncatewords:100 }}{% endif %}{% endblock %}

{% block link %}
  {{ block.super }}
  <link rel="alternate" type="application/rss+xml" title="{% trans "RSS Feed of discussions on" %} '{{ object.title }}'" href="{% url zinnia_entry_discussion_feed object.slug %}" />
  <link rel="alternate" type="application/rss+xml" title="{% trans "RSS Feed of comments on" %} '{{ object.title }}'" href="{% url zinnia_entry_comment_feed object.slug %}" />
  <link rel="alternate" type="application/rss+xml" title="{% trans "RSS Feed of pingbacks on" %} '{{ object.title }}'" href="{% url zinnia_entry_pingback_feed object.slug %}" />
  <link rel="alternate" type="application/rss+xml" title="{% trans "RSS Feed of trackbacks on" %} '{{ object.title }}'" href="{% url zinnia_entry_trackback_feed object.slug %}" />
{% endblock %}

{% block content %}
<div id="entry-{{ object.pk }}" class="hentry{% if object.featured %} featured{% endif %} span-16 last">
  {% with object.html_content|safe as object_content %}
  {% include "zinnia/_entry_detail.html" %}
  {% endwith %}
</div>

<hr />

<div class="entry-widgets span-16 last">
  {% with object.next_entry as next_entry %}
  {% if next_entry %}
  <div class="entry-next">
    <h3>{% trans "Next entry" %}</h3>
    <ul>
      <li>
	<a href="{{ next_entry.get_absolute_url }}" title="{{ next_entry.title }}" rel="next">
	  {{ next_entry.title }}
	</a>
      </li>
    </ul>
  </div>
  {% endif %}
  {% endwith %}
  {% with object.previous_entry as previous_entry %}
  {% if previous_entry %}
  <div class="entry-previous">
    <h3>{% trans "Previous entry" %}</h3>
    <ul>
      <li>
	<a href="{{ previous_entry.get_absolute_url }}" title="{{ previous_entry.title }}" rel="prev">
	  {{ previous_entry.title }}
	</a>
      </li>
    </ul>
  </div>
  {% endif %}
  {% endwith %}
  {% if object.related_published_set %}
  <div class="entry-related">
    <h3>{% trans "Related entries" %}</h3>
    <ul>
      {% for entry in object.related_published_set %}
      <li>
	<a href="{{ entry.get_absolute_url }}" title="{{ entry.title }}" rel="bookmark">{{ entry.title }}</a>
      </li>
      {% endfor %}
    </ul>
  </div>
  {% endif %}
  <div class="entry-similar">
    <h3>{% trans "Similar entries" %}</h3>
    {% get_similar_entries 5 %}
  </div>
</div>

<hr />

<div id="comments" class="span-16 last">
  <h3>{% trans "Comments" %}</h3>
  {% with object.comments as comment_list %}
  {% if comment_list.count %}
  <ol id="comment-list" class="span-15 last">
    {% for comment in comment_list %}
    <li id="comment_{{ comment.pk }}" class="comment vcard {% cycle box1,box2 %}{% if comment.user in object.authors.all %} post-author{% endif %} span-15 last">
      <div class="span-2">
	<img src="{% get_gravatar comment.email 60 "G" %}" class="gravatar photo" alt="{{ comment.user_name }}"/>
      </div>
      <div class="comment-body span-13 last">
	<div class="comment-author span-13 last">
	  {% if comment.url %}
	  <a href="{{ comment.url }}" class="fn url">{{ comment.user_name }}</a>
	  {% else %}
	  {{ comment.user_name }}
	  {% endif %}
	  {% trans "on" %} {{ comment.submit_date|date:"SHORT_DATETIME_FORMAT" }}
	</div>
	<div class="span-13 last">
	  <cite>
	    {{ comment.comment }}
	  </cite>
	</div>
      </div>
    </li>
    {% endfor %}
  </ol>
    {% if not object.comment_enabled %}
  <p>{% trans "Comments are closed." %}</p>
    {% endif %}
  {% else %}
    {% if object.comment_enabled %}
  <p>{% trans "No comments yet." %}</p>
    {% else %}
  <p>{% trans "Comments are closed." %}</p>
    {% endif %}
  {% endif %}
  {% endwith %}
</div>

<hr />
<div id="pingbacks" class="span-16 last">
  <h3>{% trans "Pingbacks" %}</h3>
  {% with object.pingbacks as pingback_list %}
  {% if pingback_list.count %}
  <ol id="pingback-list" class="span-15 last">
    {% for pingback in pingback_list %}
    <li id="pingback_{{ pingback.pk }}" class="pingback {% cycle box1,box2 %} span-15 last">
      <div class="pingback-body span-15 last">
	<div class="pingback-author span-15 last">
	  <a href="{{ pingback.url }}">{{ pingback.user_name }}</a>
	  {% trans "on" %} {{ pingback.submit_date|date:"SHORT_DATETIME_FORMAT" }}
	</div>
	<div class="span-15 last">
	  <cite>
	    {{ pingback.comment }}
	  </cite>
	</div>
      </div>
    </li>
    {% endfor %}
  </ol>
  {% endif %}
    {% if object.pingback_enabled %}
  <p>{% trans "Pingbacks are open." %}</p>
    {% else %}
  <p>{% trans "Pingbacks are closed." %}</p>
    {% endif %}
  {% endwith %}
</div>

<hr />
<div id="trackbacks" class="span-16 last">
  <h3>{% trans "Trackbacks" %}</h3>
  {% with object.trackbacks as trackback_list %}
  {% if trackback_list.count %}
  <ol id="trackback-list" class="span-15 last">
    {% for trackback in trackback_list %}
    <li id="trackback_{{ trackback.pk }}" class="trackback {% cycle box1,box2 %} span-15 last">
      <div class="trackback-body span-15 last">
	<div class="trackback-author span-15 last">
	  <a href="{{ trackback.url }}">{{ trackback.user_name }}</a>
	  {% trans "on" %} {{ trackback.submit_date|date:"SHORT_DATETIME_FORMAT" }}
	</div>
	<div class="span-15 last">
	  <cite>
	    {{ trackback.comment }}
	  </cite>
	</div>
      </div>
    </li>
    {% endfor %}
  </ol>
  {% endif %}
    {% if object.pingback_enabled %}
  <p><a href="{% url zinnia_entry_trackback object.slug %}" rel="trackback">{% trans "Trackback URL" %}</a></p>
    {% endif %}
  {% endwith %}
</div>

{% if object.comment_enabled %}
<div class="commentForm span-16 last">
  {% render_comment_form for object %}
</div>
{% endif %}

{% endblock %}

{% block admin_tools %}
{% if perms.zinnia.change_entry %}
<li>
  <a href="{% url admin:zinnia_entry_change object.pk %}" title="{% trans "Edit the entry" %}">
    {% trans "Edit the entry" %}
  </a>
</li>
{% endif %}
{% endblock %}
